#ifndef  NF_SOCS_LOCALNODE_H
#define  NF_SOCS_LOCALNODE_H
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/netdevice.h>
#include "socs/comm/constants.h"
#include "socs/mod/addr_opt.h"

struct locallink {
	char name[IFNAMSIZ];//just remember  eth0 or eth1...
	socs_addr_t address;
	unsigned int sapcnt;
	struct timer_list timer;
	atomic_t totalrq;
};
struct localnode {
	char hostname[HOSTNAMESIZE];
	int family; /*it may be IPV4 or IPV6*/
	unsigned int totalsapcnt; /**/
	unsigned int lcl_num; /*num of locallink*/
	struct locallink lcls[0];

};

#define SIZEOFLCL     sizeof(struct locallink)
#define SIZEOFLCN     sizeof(struct localnode)
#define node_for_each_link(pos,node) for(pos=0;pos<(node)->lcl_num;pos++)
/**********************************API for locallink*****************************************/
int locallink_addr_cmp(int famliy, struct locallink *lcl, void *address);
int locallink_remove(struct localnode *lcn, void *address,
					 int is_localnode); //modify by Leo.Huang 2015-02-28
void locallink_remove_all(struct localnode *lcn);
struct locallink *locallink_find_best(struct localnode *lcn);
int locallink_decsapcnt(struct localnode *lcn, void *address);
int locallink_incsapcnt(struct localnode *lcn, void *address);
/**********************************API for localnode**************************************/
void  locallink_expire(unsigned long data);
void  locallink_expire_now(struct locallink *lcl);
int  localnode_settimer(struct localnode *lcn, int is_localnode);
int localnode_update(struct localnode *old , struct localnode *new);
void localnode_show(struct localnode *lcn);
int localnode4_get(struct net_device *dev , struct localnode *lcn);
int localnode6_get(struct net_device *dev , struct localnode *lcn);
int localnode_get(struct localnode *lcn, int family);

#endif
